﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    var Department = ViewBag.Department as Domain.SYS_DEPARTMENT;
}
@model Common.PageInfo
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">                   
                        <div class="ibox-title">
                            <h5>@Department.NAME - 下属岗位</h5>                           
                            <div class="ibox-tools">
                                <a class="btn btn-primary btn-xs p210" id="insert" action="add"><i class="fa fa-plus-circle fa-fw"></i> 创建新岗位</a>
                                <a class="btn btn-warning btn-xs p210" id="modify" action="edit"><i class="fa fa-pencil fa-fw"></i> 编辑</a>
                                <a class="btn btn-danger btn-xs p210" id="delete" action="remove"><i class="fa fa-trash-o fa-fw"></i> 删除</a>                                
                                <a class="reload-link" style="color: #c4c4c4" href="javascript:dig.reload()" data-toggle="tooltip" data-placement="left" title="刷新">
                                    <i class="fa fa-repeat fa-lg"></i>
                                </a>
                            </div>

                        </div>
                        <div class="ibox-content">
                            @using (Ajax.BeginForm("Index", null, new AjaxOptions() { }, new { @id = "form1", @class = "form-horizontal", @method = "get" }))
                    {
                    <div class="row">
                        <div class="col-sm-9">
                            <label>岗位类型：</label>
                            @Html.Hidden("departId", Department.ID)
                            <select id="posttype" name="posttype" class="form-control input-sm  input-s-sm inline" onchange="submit()">
                                <option value="" @(ViewData["post"] == null ? "selected=\"selected\"" : "")>全部</option>
                                @{
                        var postType = ViewData["PostType"] as List<Domain.SYS_CODE>;
                        foreach (var item in postType)
                        {
                                    <option value="@item.CODEVALUE" @(ViewData["post"] != null && ViewData["post"].ToString() != "" && ViewData["post"].ToString() == item.CODEVALUE ? "selected=\"selected\"" : "")>@item.NAMETEXT</option>
                        }
                                }
                            </select>



                        </div>
                        <div class="col-sm-3">
                            <div class="input-group">
                                @Html.TextBox("Search", null, new { @class = "input-sm form-control", @placeholder = "请输入查询关键词" })
                                <span class="input-group-btn">
                                    <button type="submit" onclick="submit()" class="btn btn-sm btn-primary"> 搜索</button>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <table id="dataTable" class="table table-striped table-bordered table-hover dataTables-example" style="text-align:center;">
                            <thead>
                                <tr>
                                    <th class="tn" style="width: 50px !important"><input name="checkall" class="icheck_box" type="checkbox" value=""></th>
                                    <th>岗位名称</th>
                                    <th>岗位类型</th>
                                    <th>员工数量</th>
                                    <th>创建时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                @{foreach (var item in Model.List)
                                {
                                <tr>
                                    <td class="tn">
                                        <input name="checkbox_name" class="icheck_box" type="checkbox" value="@item.ID" />
                                    </td>
                                    <td><a href="javascript:EditPost('@item.ID')" listaction="detail" data-toggle="tooltip" data-placement="right" title="修改"> @Html.Raw(item.POSTNAME)</a></td>
                                    <td>@item.POSTTYPE</td>
                                    <td>@item.USERCOUNT</td>
                                    <td>@item.CREATEDATE</td>
                                </tr>
                                }
                                }
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="dataTables_info">
                                显示 @Model.BeginPage 到 @Model.EndPage 项，共 @Model.Count 项, 每页显示
                                <select name="example_length" class="form-control input-sm input-xs-sm inline" onchange="submit()">
                                    <option value="10" @(Model.PageSize == 10 ? "selected" : "")>10</option>
                                    <option value="25" @(Model.PageSize == 25 ? "selected" : "")>25</option>
                                    <option value="50" @(Model.PageSize == 50 ? "selected" : "")>50</option>
                                    <option value="100" @(Model.PageSize == 100 ? "selected" : "")>100</option>
                                </select> 条记录
                            </div>
                        </div>
                        <div class="col-sm-6">
                            @WebPages.CommonHtmlHelper.PaginationPager(Model.Index, Model.PageSize, Model.Count, 7, Model.Url)
                        </div>
                    </div>
                    }
                        </div>

            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        //点击修改
        function EditPost(n) {
            dig.addPage('编辑岗位', '/Sys/Post/Detail/' + n, 600, 475, function () {
                if (this.returnValue == 'yes') {
                    location.reload();
                }
            });
        }
        $(function () {
            //添加
            $('#insert').click(function () {
                var departId = $('#departId').val();
                if (departId == '' || departId == undefined) {
                    dig.error("请先选择部门后再进行添加岗位操作！");
                    return;
                }
                dig.addPage('添加岗位', '/Sys/Post/Detail?departId=' + departId, 600, 475, function () {
                    if (this.returnValue == 'yes') {
                        location.reload();
                    }
                });
            });
            //修改
            $('#modify').click(function () {
                var vals = '';
                var num = 0;
                $('input[name="checkbox_name"]:checked').each(function () {
                    vals = $(this).val();
                    num++;
                });
                if (!vals) {
                    dig.error("对不起，请选中您要操作的记录！");
                    return;
                }
                if (num > 1) {
                    dig.error("对不起，每次只能修改一条记录！");
                    return;
                }
                dig.addPage('编辑岗位', '/Sys/Post/Detail/' + vals, 600, 475, function () {
                    if (this.returnValue == 'yes') {
                        location.reload();
                    }
                });
            });
        });
    </script>
}

